1 using UnityEngine;
2 using
System.Collections;
3
4 public
class CameraRotation : MonoBehaviour
5 {
6
7     
// Use this for initialization
8     
void Start()
9     {
10     }
11
12     
// Update is called once per frame
13     
void Update()
14     {
15         
float rotationSpeed = 5.0f;
16         
float mouseX = Input.GetAxis("Mouse X") * rotationSpeed;
17         
float mouseY = Input.GetAxis("Mouse Y") * rotationSpeed;
18
19         transform.localRotation = Quaternion.Euler(
0, mouseX, 0) * transform.localRotation;
20         Camera camera = GetComponentInChildren<Camera>();
21         camera.transform.localRotation = Quaternion.Euler(-mouseY,
0, 0) * camera.transform.localRotation;
22     }
23 }


Gõ tìm kiếm nhanh...